<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/RanchBuddy.Master" Inherits="RanchBuddy.Web.Services.MyViewPage<RanchBuddy.Core.Domain.Impl.Company>" %>
<%@ Import Namespace="RanchBuddy.Core.Domain"%>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
	<title>Create</title>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <%= Html.ValidationSummary() %>

    <% using (Html.BeginForm()) {%>

        <fieldset>
            <legend>New Company</legend>
            <div style="float:left;">
            <p>
                <label for="Name">Name:</label>
                <%= Html.TextBox("Name") %>
                <%= Html.ValidationMessage("Name", "*") %>
            </p>
            <p>
                <label for="WebsiteURL">Website URL:</label>
                <%= Html.TextBox("WebsiteURL") %>
                <%= Html.ValidationMessage("WebsiteURL", "*") %>
            </p>
            <p>
                <label for="Email">Email:</label>
                <%= Html.TextBox("Email") %>
                <%= Html.ValidationMessage("Email", "*") %>
            </p>
            <p>
                <label for="Phone1">Phone 1:</label>
                <%= Html.TextBox("Phone1") %>
                <%= Html.ValidationMessage("Phone1", "*") %>
            </p>
            <p>
                <label for="Phone2">Phone 2:</label>
                <%= Html.TextBox("Phone2") %>
                <%= Html.ValidationMessage("Phone2", "*") %>
            </p>
            <p>
                <label for="Address1">Address1:</label>
                <%= Html.TextBox("Address1") %>
                <%= Html.ValidationMessage("Address1", "*")%>
            </p>
            <p>
                <label for="Address2">Address2:</label>
                <%= Html.TextBox("Address2")%>
                <%= Html.ValidationMessage("Address2", "*")%>
            </p>
            <p>
                <label for="City">City:</label>
                <%= Html.TextBox("City") %>
                <%= Html.ValidationMessage("City", "*")%>
            </p>
            <p>
                <label for="State">State:</label>
                <%= Html.TextBox("State")%>
                <%= Html.ValidationMessage("State", "*")%>
            </p>
            <p>
                <label for="ZipCode">Zip Code:</label>
                <%= Html.TextBox("ZipCode") %>
                <%= Html.ValidationMessage("ZipCode", "*") %>
            </p>
            <p>
                <label for="Latitude">Latitude:</label>
                <%= Html.TextBox("Latitude")%>
                <%= Html.ValidationMessage("Latitude", "*")%>
            </p>
            <p>
                <label for="Longitude">Longitude:</label>
                <%= Html.TextBox("Longitude")%>
                <%= Html.ValidationMessage("Longitude", "*")%>
            </p>
            <p>
                <label for="CompanyType">Company Type:</label>
                <select name="CompanyType">
                <%
                foreach (CompanyType t in ViewData["CompanyTypes"] as List<CompanyType>)
                {%>
                    <option value="<%=t.CompanyTypeID %>"><%= t.Name %></option>
                <%}
                %>
                </select>
            </p>
            <p>
                <input type="submit" value="Create" />
            </p>
            </div>
            <br />
            <div id="mapDiv">
            <% Html.RenderPartial("Map", Model); %>
            </div>
            
        </fieldset>
        <script type="text/javascript">
            $(document).ready(function() {
                $("#ZipCode").blur(function(evt) {
                    $("#Latitude").val("");
                    $("#Longitude").val("");

                    var address = jQuery.trim($("#Address1").val()) + " " + jQuery.trim($("#Address2").val()) + " " + jQuery.trim($("#City").val()) + " " + jQuery.trim($("#State").val()) + " " + jQuery.trim($("#ZipCode").val());
                    if (address.length < 1)
                        return;

                    FindAddressOnMap(address);
                });
            });
        </script>
        
    <% } %>

    <div>
        <%=Html.ActionLink("Back to List", "Index") %>
    </div>

</asp:Content>

